import time
import get_time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import shutil


# 1、创建浏览器对象 - 打开浏览器
# driver = webdriver.Chrome("C:\Program Files\Google\Chrome\Application\chrome.exe")
s = Service(executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe')
driver = webdriver.Chrome(service=s)

# 2、打开测试网页首页
driver.get("https://beta-actest.wesais.cn/#/login")

# 3、输入账号密码
driver.find_element(By.CLASS_NAME,'el-input__inner').send_keys('mo')
driver.find_element(By.NAME,'password').send_keys('q12345678')

time.sleep(1)   #等待1秒
# 4、点击登录
element = driver.find_element(By.CLASS_NAME, 'el-button')
driver.execute_script("arguments[0].click();", element)

time.sleep(3)   #等待1秒
# 5、点击场馆营业
# element = driver.find_element(By.XPATH, '/html/body/div[1]/div/div/section/div/div[2]/div/div[5]/div/img')
# driver.execute_script("arguments[0].click();", element)

elements = driver.find_elements(By.CLASS_NAME,'app-item')
for element in elements:
   c_element= element.find_element(By.TAG_NAME,"span")
   if '场馆营业' ==c_element.text:
       driver.execute_script("arguments[0].click();",c_element)

driver.save_screenshot('/Users/Administrator/Pictures/Saved Pictures/截图01.png')

time.sleep(3)   #等待1秒
# 6、下拉场馆
handles = driver.window_handles
driver.switch_to.window(handles[1])
element = driver.find_element(By.XPATH, '/html/body/div[1]/div/div[1]/div[1]/div/ul/div[1]/div/div')
driver.execute_script("arguments[0].click();", element)

time.sleep(1)
# 7、选择场馆
element = driver.find_element(By.XPATH, '/html/body/ul/li[3]/li[2]')
driver.execute_script("arguments[0].click();", element)

time.sleep(1)
# 8、进入场馆
element = driver.find_element(By.XPATH, '/html/body/div[1]/div/div[1]/div[1]/div/ul/div[4]/li/div')
driver.execute_script("arguments[0].click();", element)

# 9、场地预定
element = driver.find_element(By.XPATH, '/html/body/div[1]/div/div[1]/div[1]/div/ul/div[4]/li/ul/div[1]/a/li/span')
driver.execute_script("arguments[0].click();", element)














time.sleep(5)
driver.quit()




